/**
 * 
 */
package org.domain.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.SecurityContext;

/**
 * @author asudar
 * 
 */
@Path("/hello")
public class HelloWorld {

	@GET
	@Produces(value = MediaType.TEXT_PLAIN)
	public String getMessage(@Context SecurityContext securityContext) {

		if (securityContext.isUserInRole("admin")) {
			return "Hello, World !";

		}

		throw new SecurityException("User is unauthorized !");
	}

	@GET
	@Path("/json")
	@Produces(value = MediaType.APPLICATION_JSON)
	public String getJson() {
		return "Welcome, JSON";
	}
}
